import { apiService } from './api';
import type { Movies, MovieSeasons, MovieEpisodes, MovieDetails } from '../dataType/movieType';
import type { PageResponse } from '../dataType/pageType';

// 电影服务类
export const movieService = {
  /**
   * 获取电影列表
   * @returns 电影列表数据
   */
  getMovies: (pageNum: number, pageSize: number,type:string='0',keyword:string=''): Promise<PageResponse<Movies>> => apiService.get<PageResponse<Movies>>('/api/movie/listPage', { params: { pageNum, pageSize,type,keyword } }),

  /**
   * 获取单个电影详情
   * @param id 电影ID
   * @returns 电影详情数据
   */
  getMovieById: (id: string): Promise<Movies> => apiService.get<Movies>(`/api/movie/${id}`),

  addMovie: (movie: Movies): Promise<void> => apiService.post<void>(`/api/movie`, movie),
  updateMovie: (movie: Movies): Promise<void> => apiService.put<void>(`/api/movie`, movie),
  deleteMovie: (id: number): Promise<void> => apiService.delete<void>(`/api/movie/${id}`),
  /**
   * 获取电影季列表
   * @param movieId 电影ID
   * @returns 电影季列表数据
   */
  getMovieSeasonsByMovieId: (movieId: number): Promise<MovieSeasons[]> => apiService.get<MovieSeasons[]>(`/api/movie/seasons/${movieId}`),

  addMovieSeason: (movieSeason: MovieSeasons): Promise<void> => apiService.post<void>(`/api/movie/seasons`, movieSeason),
  updateMovieSeason: (movieSeason: MovieSeasons): Promise<void> => apiService.put<void>(`/api/movie/seasons`, movieSeason),
  deleteMovieSeason: (id: number): Promise<void> => apiService.delete<void>(`/api/movie/seasons/${id}`),
  /**
   * 获取电影剧集详情
   * @param id 剧集ID
   * @returns 电影剧集详情数据
   */
  getMovieEpisodeBySeasonId: (seasonId: number): Promise<MovieEpisodes[]> => apiService.get<MovieEpisodes[]>(`/api/movie/episodes/${seasonId}`),

  addMovieEpisode: (movieEpisode: MovieEpisodes): Promise<void> => apiService.post<void>(`/api/movie/episodes`, movieEpisode),
  updateMovieEpisode: (movieEpisode: MovieEpisodes): Promise<void> => apiService.put<void>(`/api/movie/episodes`, movieEpisode),
  deleteMovieEpisode: (id: number): Promise<void> => apiService.delete<void>(`/api/movie/episodes/${id}`),
  /**
   * 获取电影剧集详情
   * @param id 剧集ID
   * @returns 电影剧集详情数据
   */
  getMovieEpisodeById: (id: number): Promise<MovieEpisodes> => apiService.get<MovieEpisodes>(`/api/movie/episodesOnly/${id}`),
};